
/*设置cookie*/
export function setCookie(name: string, value: string | number, day?: number) {
    let expires = ''
    if(day) {
        const oDate = new Date()
        oDate.setDate(oDate.getDate() + day)
        expires = ';expires=' + oDate
    }
    document.cookie = name + '=' + value + expires
}

/*获取cookie*/
export function getCookie(name: string) {
    return document.cookie.match(new RegExp('(^| )' + name + '=([^;]*)(;|$)'))?.[2] || ''
}

/*删除cookie*/
export function removeCookie(name: string) {
    setCookie(name, 1, -1)
}